package com.w.picture.mode.enums;

import java.util.Arrays;
import java.util.List;

/**
 * @Title: FileUploadBizEnum
 * @Author wzp
 * @Date 2024/12/31 16:00
 * @description: 文件上传业务场景枚举，用于区分不同业务场景下的文件上传规则和路径。
 */
public enum FileUploadBizEnum {
    /**
     * 用户头像上传场景。
     * - 最大文件大小：2MB
     * - 允许的文件格式：jpeg, jpg, png
     * - 上传路径前缀：/avatar
     */
    AVATAR("avatar", 2 * 1024 * 1024, Arrays.asList("jpeg", "jpg", "png"), "/avatar"),

    /**
     * 产品图片上传场景。
     * - 最大文件大小：5MB
     * - 允许的文件格式：jpeg, jpg, png, webp
     * - 上传路径前缀：/product/image
     */
    PRODUCT_IMAGE("product_image", 5 * 1024 * 1024, Arrays.asList("jpeg", "jpg", "png", "webp"), "/product/image"),

    /**
     * 文档上传场景。
     * - 最大文件大小：10MB
     * - 允许的文件格式：pdf, doc, docx
     * - 上传路径前缀：/document
     */
    DOCUMENT("document", 10 * 1024 * 1024, Arrays.asList("pdf", "doc", "docx"), "/document"),

    /**
     * 通用图片上传场景。
     * - 最大文件大小：5MB
     * - 允许的文件格式：jpeg, jpg, png, webp
     * - 上传路径前缀：/general/image
     */
    PUBLIC_IMAGE("public_image", 5 * 1024 * 1024, Arrays.asList("jpeg", "jpg", "png", "webp"), "/public/image"),
    /**
     * 空间图片上传场景。
     * - 最大文件大小：5MB
     * - 允许的文件格式：jpeg, jpg, png, webp
     * - 上传路径前缀：/general/image
     */
    SPACE_IMAGE("space_image", 5 * 1024 * 1024, Arrays.asList("jpeg", "jpg", "png", "webp"), "/public/image"),
    ;

    private final String bizCode;
    private final long maxSize; // in bytes
    private final List<String> allowedFormats;
    private final String uploadPathPrefix;

    FileUploadBizEnum(String bizCode, long maxSize, List<String> allowedFormats, String uploadPathPrefix) {
        this.bizCode = bizCode;
        this.maxSize = maxSize;
        this.allowedFormats = allowedFormats;
        this.uploadPathPrefix = uploadPathPrefix;
    }

    public String getBizCode() {
        return bizCode;
    }

    public long getMaxSize() {
        return maxSize;
    }

    public List<String> getAllowedFormats() {
        return allowedFormats;
    }

    public String getUploadPathPrefix() {
        return uploadPathPrefix;
    }
}